Skip to content

fix(codegen): reject the #746 Crypto externs on core WASM by name (#822) - #823

Merged
hyperpolymath merged 2 commits into
mainfrom
fix/822-wasm-crypto-unsupported
Nov 27, 2026
Merged

hyperpolymath merged 2 commits into
mainfrom
fix/822-wasm-crypto-unsupported

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Closes #822. Refs #746.

Summary

The 6 Crypto externs from #746 (sha256, hmac_sha256, base64url_encode, base64url_decode, rsa_sign_pkcs1_sha256, rsa_verify_pkcs1_sha256) compiled on core WASM to host imports that no host supplies. The module then failed at load with a LinkError.

gen_imports (lib/codegen.ml) now gives a named error when a program uses one:
Crypto.sha256 is not supported on the core-WASM backend; compile with --bun-esm (#822).
An unused import of one is dropped, so the program still compiles.

This is the interim that #746 proposes for typed-wasm. The other Crypto externs (random_string, random_f64, time_ms) are unchanged.

Tests

  • 2 new e2e tests: a use is rejected by name; an unused import compiles. The first fails on main.
  • Suites: e2e 659, WASM 47, Bun-ESM 41, native Bun 8. All pass.

Generated by Claude Code

@gitnotebooks

gitnotebooks Bot commented Nov 27, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8fa11f7c-32a5-4a70-83e2-e46391c462cc
Commits

Reviewing files that changed from the base of the PR and between bb595b9 and 00f9ae4.

Files selected for processing: 2

  • lib/codegen.ml
  • test/test_e2e.ml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@hyperpolymath
hyperpolymath marked this pull request as ready for review November 27, 2026 01:07
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-27T01:07:40.416477Z
We couldn’t complete this review. Comment @codex review to try again.
11c59fa Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@hyperpolymath
hyperpolymath force-pushed the fix/822-wasm-crypto-unsupported branch from d523022 to 51c95b5 Compare November 27, 2026 01:38
The 6 Crypto externs from #746 compiled to host imports that no
core-WASM host supplies, so the module failed at load with a LinkError.

A use is now a named compile error that points to --bun-esm. An unused
import of one is dropped.

Closes #822

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136P7ZjyGGiPhiEUxNGPwsr
@hyperpolymath
hyperpolymath force-pushed the fix/822-wasm-crypto-unsupported branch from 51c95b5 to 00f9ae4 Compare November 27, 2026 02:07
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit e94a5f9 into main Nov 27, 2026
18 checks passed
@hyperpolymath
hyperpolymath deleted the fix/822-wasm-crypto-unsupported branch November 27, 2026 02:16
hyperpolymath added a commit that referenced this pull request Nov 27, 2026
… name (#815) (#824)

Refs #815

Replaces #820. A push error of mine put main's tip on the #820 branch,
so GitHub closed #820 as "merged" with no change. This PR has the same
change, rebased on main (after #823). The only new work is the conflict
in test/test_e2e.ml: both PRs add tests to `modmut561_tests`, and this
PR keeps both sets.

## Summary
- `program_free_names` (lib/codegen.ml) now skips a fn's own parameter
names. A parameter named `log` under `use Console;` no longer adds a
`Console.log` import.
- `lower_qualified_value_paths` (lib/resolve.ml) tracks the local
binders in scope: let, lambda, match, handler, for and fn params.
- When a local captures a qualified `Mod.f` call, resolve gives a clear
error: "`Mod.fn` is shadowed by a local `fn` in scope; rename the
local". Before, that program linked wrong.

## Gap that remains
Issue test 2 (same param plus a qualified call: import kept and links)
now gives the clear error. It does not compile yet. Full support needs
the qualifier carried through the type checker and the backends (size
L). This PR uses "Refs", not "Closes".

## Tests
- 3 new e2e tests: param only (no import), qualified call (import kept),
capture (error).
- `dune runtest` main suite: 662 tests pass (659 on main plus these 3).

---
_Generated by [Claude Code](https://claude.ai/code)_

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codegen(wasm): Crypto externs from #746 compile to unsupplied host imports (LinkError at load)

3 participants